Make less ugly, start writing unit tests