Cleaned up project a little bit, wrote automata tests