Forgot to add author, date and license. Some code cleanup.