Fixed a nasty tail bug