fix possible out-of-bounds write [coverity]
fix casting to doubles
initialize all member variables