Fixed some issues caused by the refactoring