Bug fixes, improved guard class