Some small changes based on Apple Sample Code