Finalized code for the guard command

fixes #44
fixes #146
fixes #148
fixes #149