Changes in texture code & refactoring

 * refactored and altered slightly the texture pack code
 * added flushing of texture cache
 * some refactoring and const-correctness in CApplication methods