added license headers
added better sorting support