minor improvements (null checking, array initializations)