added license headers and cleaned up some code