book code improvements, thanks Niphlod