Moved all state logic into the component core and cleaned up codebase a little.