Added names to Q
Fixed bugs in weight optimizer