Moved some code and removed some stuff