Fixed some flask bugs