Fixed bug #355 and other minor errors