code cleanup, added license and header