Added FTP functionality and cleaned-up code