Bug fix

Fix #79
Fix #56
Fix #81