Restructured a bit to save some memory

Got rid of some unnecessary object creation and continued to work on the
IDA* method. Having problems with stack overflow at the moment