Correct Knowledge Unit string representation.
Use db queries to perform data retrieval and preparation.
Cleanup environment variable access.
Whitespace cleanup, use bash instead of sh.