Adding some fixes and cleanups