Complete module rewrite, upgrade to APIv3