Some basic bug fixes