Added more basic functionality and refactored