This commit is just crazy with the amount of changes, but it works