Better error reporting and argumet sorting