Fixed issues reported by @cdeil