Fixes a myriad of bugs
Fixes a myriad of bugs