fixed issues reported by Danny Stefanic. Thanks.