Added basic AI and some minor bug fixes