Commented and cleaned code