Some code and lib clean-up