Fixing some implementation bugs
Fixing some implementation bugs