Some code cleanup and argument checking

Also little changes to README.md