Fixing types, adding some new functions