rearranged some stuff and added license headers