Revert "Revert "Bugs fixed""

This reverts commit d421a65a5b03037bea0cc3b2464cedc4eeaddfd0.
33