Cleaned up constant usage
Added additional safety checks
Added additional checks