Fix errors and introducing layer control

Fix some errors, #289, #431, #349, add layer control directive under development.