Refactoring. Added correct file transfer. Added socket events.