Various fixes to functionality