Added more comments, fixed naming and other small stuff.