Added licence and cleaned up a little