Added file extension feature and cleaned code.