Fixes errors, improves formatting