added debug toggle and comments