Minor bugfix in memory allocation