final commit, finished cleaning up and combined into main.c