Add edit post feature and some refactorings