Fixed some more issues
Almost all issues have been fixed, needs another test and probably another revision