Fix data loss and perfomance warnings.
Fix warnings in core and base