Further code clean up and some inner new stuff