Fixing code and typos