-code cosmetics and added a debug flag