Cleanup code a bit and start adding gecoding support