Implemented majority of functionality.