Implement almost all functionality, needs refactoring and small bug fixes