Function optimizations possibly fixed