Update with changes to fix several bugs and reduce compiler warnings