Bug fixes after merge