Log script errors

@demmer rebase and fixed some things