Added some functions, refactored code