Improved documentation and readme. Minor bug fixes and code clean-up.