Some improvements (by Vlad Kochemaev)