Fixed some bugs?

I set the Beta and W to None when it's not passed in. That didn't seem to have an effect but mine as well make use of the if statements

I found a few instances were the index variables felt wrong to me. I didn't review the math but they seemed off. 

Please review

Thanks
Adam