Cleanup, Reorganize code, fix formatting, change thumbnail format to PNG to avoid a weird transparency issue.