Added license header.
Cleanup and renamed some methods for clarity purposes.