Reduce memory usage, fixed build warnings