Fix memory leak/have more consistent style