Fixed wrong behavior of string.gsub() + added support for functions as replacement