Better aargument parsing and code cleanups