Organized and improved code style

This were just too much lines in one file, sorry :D