Fixed bug in build.xml and added some error handling