Fixed #4 and #6 + some sql security issues.