Added -debug flag and started using log package