Fixed value setting from unity

Fixed val setting. Before all values where assinged to keys values. Fixed compilation when CUSTOM_EXCEPTION defined.