Small improvements

Working on fixing a couple of warning and improving performance where possible.