Fix some calculator bugs