Changed queries to EntityFieldQuery, cleaned code, fixed Drupal race conditions, added proper field deletion on uninstall.