Everything re-written from scratch in a more OO manner