Cleaned up code.

Subbed out to a select fragment to make the code easier to understand.
Added LICENSE to two files.