Fix small bugs introduced with refactoring