Bug fixes

Various bug fixes, most of them didn't have issues.