license

Added licence and cleaned up some code.