small optimization to the update of the W matrix (should be a little bit faster now and is also in line with the derivation in the thesis)
merged W update optimization from master