Fix some smaller bugs and refactor away some warnings