Turned everything into functions and classes