Commented and refactored the structure a little