Refactor API code. Add stored procedures.