Some improvements and tests