Added 3.x support

Basic port to 3.x
Tested with 3.4 and everything worked fine