Fixing bugs and adding enhancements for issues #2, #5, and #8