Initial commit
Attempt to structure the logic in a functional way. Implements basic
logic with almost no error detection