Added license to all files and cleaned up code a little bit