Changes from the original repository

A lot of changes for OTP17 compatible