added new macros and fixed bugs in add_app