Cleaned up code and fixed bug with sparklines