Update for Mac compatibility and cleanup.