minor fixes and made it more configurable