Made some changes, based on advice from @kevingranade.