autoencoders refactoring and fixes