Refactored exceptions and added format checks on variable-definition