Fixed factories and refactored reference's model
Made reference's model even cleaner