code refactoring, cleanup, gitignore

refactored code to better resemble MVC architecture, removed deprecated
code, refactored repeating code into separate methods