more changes, fixed some bugs in the code, -gateway will work now, added