Introducing HAL, the AI, in support of #162. Also some minor bugfixes & cleanup.