Code complexity fixes