Implemented StateManager and Components, and fixed some stuff.