Refactors note plugin to use db
Adds note plugin SQL
Removes debugging code, checks array length before using