Improve memory allocation a bit #376