Cleaned up code into methods.
Map size is now read from map file.