fixes, and change NULL to nullptr for now