v3.3 ported and updated from dbcarta.googlecode.com