Refactored and added a few notes