RBM/DBN refactoring