Add some nullability annotations
Extract some methods and rename some existing methods and make some methods protected to improve sub-classability