#48 #125 Some code cleanup and minor fix to manage sidebar