use bool where appropriate
do command variable subsititution the easy way
more cleanup and RAII