Fix undefined index. Refactor functions.sql to function.sql. Inplement constants for Version numbers.