Important function fixes