Made add application to work. Fixed some bugs