Better style and more logging