First code

Most of it is just pseudo code.