Porting module for Drupal 7.

Small part fixes. Still a lot of work.

All errors - https://gist.github.com/sergeypavlenko/098727b7d1aeb25dc905