More bugfixes in train method