Fixed some code for issue #137