Code cleanup, automap working