fixed some serious pushing bugs, refactored some functions