Updates to rbm.py, better factoring into functions.