Added bug fixes from Chris