General code cleanup, license and doc update etc.