Patches

A bunch of bugs and issues patched.