now have just one function for the main loop
Optimizations and perf counters
Added space objects