renamed main file
improved code style
split out stuff into header file