Implemented better connection system.
Still gives some errors about code that works in Delphi but apparently not here. Will fix it later.