Added comments, removed some debug code