Added licence header + code cleanup