fixed error in error codes
check if summaryfile exists
removed unnecessary statefile stuff