Fixed and cleaned some stuff

Fixed most of the stuff except for the main bloody function.
All logics now work, the only thing that it does not do is send
anything.