Fixed some problems with the flat authentication