Simplify code
Silly maths error
Add metadata
Fix some formatting