Added tmx map loading support and refactor code