Added more safety checks. Closes #23