Better system commands and some code cleanup