Started returing period to SQL and creating a metaSQL for periods.
Removed unused SQL queries.