Added many little bug fixes