Fixed a bunch of small bugs introduced with the latest changes