Added support for debug param and other enhancements.