Trying to get better memory management
Moving methods to prototypes
Cleaning up some more
Utilities