Add a few new functions, bug fixes, type fixes