Fixed issue 16 in github and issue 265 in googlecode