cleaned up code a bit and added licenses