Organized the code a bit,
added a bit of comments