added object loading at beginning, refactored alot of code