Fixed numerous programming errors