Fixed several bugs introduced in the latest version