A whole bunch of changes and optimisations + autoencoder class.