added license header, code cleanup