Fixed some final bugs