Improved error checking and added support for new-style (directory-based) couchapps.