fixes for function application bugs